package com.ternnetwork.core.accesscontroll.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.ternnetwork.persistence.repository.BaseRepository;
import com.ternnetwork.core.accesscontroll.entity.User;

public interface UserRepository extends BaseRepository<User, Long> {
	
	@Query("select count(1) from User where name=?1")
	Long getCountByName(String name);
	
	
	@Query("from User where name=?1")
	List<User> findAllByName(String name);


	@Query("select t.user from UserRole t where t.role.nameEn=?1")
	List<User> findAllByRoleName(String nameEn);


	@Modifying
	@Query("update  User set password=?1  where id=?2")
	Integer updatePassword(String password,Long userId);

	@Query("from User where name!=?1 and deleted=false order by name asc")
	List<User> findAllExceptName(String name);

}
